05057b4dadde7e5b4e2dc7de0e6e7bc2a3d72f7b,src/main/java/com/treasure_data/logger/sender/HttpClient.java,HttpClient,getDatabaseNames,#,64

Before Change


    }

    public List<String> getDatabaseNames() throws IOException, APIException {
        HttpURLConnection conn = doGetRequest("/v3/database/list", null, null);
        int code = getResponseCode(conn);
        if (code != HttpURLConnection.HTTP_OK) { // not 200
            String msg = String.format("List databases failed (%d: %s)",
                    new Object[] { code, getResponseMessage(conn) });
            LOG.error(msg);
            disconnect(conn);
            throw new APIException(msg);
        }

        String jsonData = getResponseBody(conn); // TODO #MN format check
        disconnect(conn);
        Map map = (Map) JSONValue.parse(jsonData);
        Iterator<Map> dbNameMapIter = ((List) map.get("databases")).iterator();

After Change


    public List<String> getDatabaseNames() throws APIException {
        HttpURLConnection conn = null;
        String jsonData;
        try {
            conn = doGetRequest("/v3/database/list", null, null);
            int code = getResponseCode(conn);
            if (code != HttpURLConnection.HTTP_OK) {
                String msg = String.format("List databases failed (%s (%d): %s)",
                        new Object[] { getResponseMessage(conn), code, getResponseBody(conn) });
                LOG.error(msg);
                throw new APIException(msg);
            }
            jsonData = getResponseBody(conn); // TODO #MN format check
        } catch (IOException e) {
            throw new APIException(e);
        } finally {
            if (conn != null) {
                disconnect(conn);